
from datetime import datetime
import logging  
logging.basicConfig(level=logging.INFO)  

# 将毫秒格式的时间戳，转换为字符串的时间格式
def msstamp2str(msstamp, strformat='%Y-%m-%d %H:%M:%S'):
    dtTime = datetime.fromtimestamp(msstamp/1000.0)
    strtime8 = dtTime.strftime(strformat)
    return strtime8

def str2dt(strtime,strformat='%Y-%m-%d %H:%M:%S'):
    try:
        dttime=datetime.strptime(strtime, strformat)
    except:
        dttime=None

    return dttime 

def dt2str(dttime,strformat='%Y-%m-%d %H:%M:%S'):
    try:
        strtime=datetime.strftime(dttime,strformat)
    except:
        strtime=None
    return strtime


    
